﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Binding基础
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        Student student = new Student();
        public MainWindow()
        {
            InitializeComponent();

        
        






            //this.textBox.SetBinding(TextBox.TextProperty, new Binding("Name") { Source = student = new Student() });

            //Binding binding = new Binding();
            //binding.Source = student;
            //binding.Path = new PropertyPath("Name");
            //BindingOperations.SetBinding(this.textBox, TextBox.TextProperty, binding);
        }

        private void button_Click(object sender, RoutedEventArgs e)
        {
            student.Name += "Name";


        }
    }


   

    class Student : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;
        private string name;

        public string Name
        {
            get { return name; }
            set
            {
                name = value;
                if (PropertyChanged != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs("Name"));
                }
            }
        }
    }
}
